package com.jiaoyou.baojian.adapter;

import android.text.TextUtils;
import android.view.View;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.jiaoyou.baojian.R;
import com.jiaoyou.baojian.activity.UserInfoActivity;
import com.jiaoyou.baojian.entity.MessageEntity;
import com.jiaoyou.baojian.entity.RoomEntity;
import com.jiaoyou.baojian.utils.Utils;

/**
 * Created by DemonZYM on 17/4/13.
 */

public class MessageAdapter extends BaseQuickAdapter<MessageEntity, BaseViewHolder> {
    public MessageAdapter() {
        super(R.layout.item_msg);
    }

    @Override
    protected void convert(BaseViewHolder helper, MessageEntity item) {
        switch (item.type){
            case 1:
                helper.setVisible(R.id.gift_msg, false);
                helper.setVisible(R.id.normal_msg, true);
                helper.setVisible(R.id.username, true);

                helper.setText(R.id.normal_msg, item.msg);
                if(!TextUtils.isEmpty(item.username))
                    helper.setText(R.id.username, item.username);
                else
                    helper.setText(R.id.username, "隔壁老王");
                break;
            case 2:
                helper.setVisible(R.id.gift_msg, true);
                helper.setVisible(R.id.normal_msg, false);
                helper.setVisible(R.id.username, false);

                helper.setText(R.id.gift_msg, item.msg);
                break;
        }
        Utils.showImage(mContext, item.avatar, (ImageView) helper.getView(R.id.avatar));
    }
}
